package com.maple.callback.event.boot.listener;

import java.util.concurrent.TimeUnit;

import org.springframework.context.event.ApplicationContextEvent;
import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;


@Component
public class BootListener {
	
	@EventListener //注解成为事件监听器
	@Async  //加入异步方法
	public void register(ApplicationContextEvent contextEvent){
		try {
			TimeUnit.SECONDS.sleep(150);  //睡眠150s
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		System.out.println("--------------->"+contextEvent.getSource());
		System.out.println("--------------->"+contextEvent.getApplicationContext());
		System.out.println("监听Spring容器的启动!");
	}
}
